﻿var NormalTable = function () {

    // Format TaiKhoan 's table
    var TaiKhoanTable = function () {
        $('#tableTaiKhoan').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        // Format checkbox
        jQuery('#tableTaiKhoan .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableTaiKhoan tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableTaiKhoan_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableTaiKhoan_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
    }


    // Format DanhMuc 's table
    var DanhMucTable = function () {
        // begin first table
        $('#tableDanhMuc').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        jQuery('#tableDanhMuc .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableDanhMuc tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableDanhMuc_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableDanhMuc_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
    }


    // Format KhachHang 's table
    var KhachHangTable = function () {
        // begin first table
        $('#tableKhachHang').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              null,
              null,
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        jQuery('#tableKhachHang .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableKhachHang tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableKhachHang_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableKhachHang_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
    }

    // Format HangHoa 's table
    var HangHoaTable = function () {
        // begin first table
        $('#tableHangHoa').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        jQuery('#tableHangHoa .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableHangHoa tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableHangHoa_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableHangHoa_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
    }

    // Format ChiTietHangHoa 's table
    var CTHangHoa = function () {
        // begin first table
        $('#tableCTHangHoa').dataTable({
            "aoColumns": [
              { "bSortable": false },
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              null,
              { "bSortable": false },
              { "bSortable": false }
            ],
            "aLengthMenu": [
                [10, 25, 50, -1],
                [10, 25, 50, "Tất cả"] // change per page values here
            ],
            // set the initial value
            "iDisplayLength": 10,
            "sPaginationType": "bootstrap",
            "oLanguage": {
                "sLengthMenu": "_MENU_ dòng",
                "oPaginate": {
                    "sPrevious": "Prev",
                    "sNext": "Next"
                }
            },
            "aoColumnDefs": [{
                'bSortable': false,
                'aTargets': [0]
            }
            ]
        });

        jQuery('#tableCTHangHoa .group-checkable').change(function () {
            var set = jQuery(this).attr("data-set");
            var checked = jQuery(this).is(":checked");
            jQuery(set).each(function () {
                if (checked) {
                    $(this).attr("checked", true);
                } else {
                    $(this).attr("checked", false);
                }
                $(this).parents('tr').toggleClass("active");
            });
            jQuery.uniform.update(set);

        });

        jQuery('#tableCTHangHoa tbody tr .checkboxes').change(function () {
            $(this).parents('tr').toggleClass("active");
        });

        jQuery('#tableCTHangHoa_wrapper .dataTables_filter input').addClass("form-control input-medium"); // modify table search input
        jQuery('#tableCTHangHoa_wrapper .dataTables_length select').addClass("form-control input-small"); // modify table per page dropdown
    }

    return {
        init: function () {
            TaiKhoanTable();
            DanhMucTable();
            KhachHangTable();
            HangHoaTable();
            CTHangHoa();
        }
    };
}

